package cn.com.blueInfo.bpm.template.entity;

import cn.com.blueInfo.bpm.common.entity.BaseEntity;
import cn.com.blueInfo.bpm.template.enums.AutomationRuleExecutionType;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自动化规则表
 * @author suxch
 * @since 2025-08-24 01:41:15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "mc_uniflow_automation_rule", autoResultMap = true)
@Schema(description = "自动化规则表")
public class AutomationRule extends BaseEntity {

    /** ID */
    @TableId(type = IdType.INPUT)
    @Schema(description = "ID")
    private Long id;
    /** 流程模板ID */
    @Schema(description = "流程模板ID")
    private Long processId;
    /** 节点ID */
    @Schema(description = "节点ID")
    private Long nodeId;
    /** 规则编码 */
    @Schema(description = "规则编码")
    private String ruleCode;
    /** 规则名称 */
    @Schema(description = "规则名称")
    private String ruleName;
    /** 触发条件表达式（如 “amount <= 1000 and dept = 'IT'”） */
    @Schema(description = "触发条件表达式（如 “amount <= 1000 and dept = 'IT'”）")
    private String conditionExpr;
    /** 执行动作类型：AUTO_PASS-自动通过，AUTO_REJECT-自动驳回，AUTO_FILL-自动填充字段 */
    @Schema(description = "执行动作类型：AUTO_PASS-自动通过，AUTO_REJECT-自动驳回，AUTO_FILL-自动填充字段")
    private AutomationRuleExecutionType executionType;
    /** 执行参数（如自动填充字段：{\"field_name\": \"audit_result\", \"value\": \"通过\"}） */
    @Schema(description = "执行参数（如自动填充字段：{\"field_name\": \"audit_result\", \"value\": \"通过\"}）")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private JSONObject executionParam;

}
